//---------------------------------------------------------------------------
#include <vcl.h>
#include <list>
#include <vector>
#include "visualizadorAbstrato.h"
#include "visualizadorArvore.h"

//---------------------------------------------------------------------------

visualizadorArvore::visualizadorArvore(float x,float y):visualizadorAbstrato(x,y)
{
	arvArvoreBinaria = new ArvoreBinaria;
};
//------------------------------------------------------------------------------
visualizadorArvore::~visualizadorArvore()
{
	delete arvArvoreBinaria;
	arvArvoreBinaria = NULL;
};
//------------------------------------------------------------------------------
void visualizadorArvore::desenha(TImage *area, double escalaX,double escalaY)const
{
		area->Canvas->Brush->Color = clTeal;
		area->Canvas->Rectangle((getX())*escalaX,(getY())*escalaY,(getX()+44)*escalaX,(getY()+44)*escalaY);
		if (escalaX == 1)
		{
				area->Canvas->Brush->Color = clWhite;
				area->Canvas->Rectangle((getX()+2)*escalaX,(getY()+6)*escalaY,(getX()+25)*escalaX,(getY()+37)*escalaY);

				//linhas da lista
				area->Canvas->MoveTo(getX()+5,getY()+10);
				area->Canvas->LineTo(getX()+20,getY()+10);

				area->Canvas->MoveTo(getX()+5,getY()+10);
				area->Canvas->LineTo(getX()+5,getY()+26);

				area->Canvas->MoveTo(getX()+5,getY()+26);
				area->Canvas->LineTo(getX()+10,getY()+26);

				area->Canvas->MoveTo(getX()+20,getY()+10);
				area->Canvas->LineTo(getX()+20,getY()+26);

				area->Canvas->MoveTo(getX()+10,getY()+10);
				area->Canvas->LineTo(getX()+10,getY()+26);

				area->Canvas->MoveTo(getX()+15,getY()+10);
				area->Canvas->LineTo(getX()+15,getY()+26);

				area->Canvas->MoveTo(getX()+20,getY()+10);
				area->Canvas->LineTo(getX()+20,getY()+26);

				area->Canvas->MoveTo(getX()+5,getY()+13);
				area->Canvas->LineTo(getX()+20,getY()+13);

				area->Canvas->MoveTo(getX()+5,getY()+16);
				area->Canvas->LineTo(getX()+20,getY()+16);

				area->Canvas->MoveTo(getX()+5,getY()+19);
				area->Canvas->LineTo(getX()+20,getY()+19);

				area->Canvas->MoveTo(getX()+5,getY()+22);
				area->Canvas->LineTo(getX()+20,getY()+22);

				area->Canvas->MoveTo(getX()+5,getY()+26);
				area->Canvas->LineTo(getX()+20,getY()+26);

				//bolinha
				area->Canvas->Brush->Color = clTeal;
				//texto
				area->Canvas->Brush->Color = clWhite;
				area->Canvas->TextOutA((getX()+6)*escalaX,(getY()+29)*escalaY,"Arvore" +IntToStr(getIdentidade()));
		}
};
//------------------------------------------------------------------------------
void visualizadorArvore::interage()
{
	TfrmArvoreBinaria * frmArvoreBinaria = new TfrmArvoreBinaria(Application, arvArvoreBinaria);
	frmArvoreBinaria->ShowModal();
	delete(frmArvoreBinaria);
	frmArvoreBinaria = NULL;
};
//------------------------------------------------------------------------------


